"""
环境数据模式
"""
from datetime import datetime
from typing import Optional, Dict, Any
from pydantic import BaseModel


class EnvironmentBase(BaseModel):
    """环境基础模式"""
    name: str
    display_name: str
    description: Optional[str] = None
    env_type: str  # dev, test, staging, prod
    base_url: Optional[str] = None
    docker_host: Optional[str] = None
    k8s_config: Optional[Dict[str, Any]] = None
    registry_config: Optional[Dict[str, Any]] = None
    resource_quotas: Optional[Dict[str, Any]] = None
    network_config: Optional[Dict[str, Any]] = None
    monitoring_config: Optional[Dict[str, Any]] = None
    backup_config: Optional[Dict[str, Any]] = None


class EnvironmentCreate(EnvironmentBase):
    """创建环境模式"""
    pass


class EnvironmentUpdate(BaseModel):
    """更新环境模式"""
    display_name: Optional[str] = None
    description: Optional[str] = None
    base_url: Optional[str] = None
    docker_host: Optional[str] = None
    k8s_config: Optional[Dict[str, Any]] = None
    registry_config: Optional[Dict[str, Any]] = None
    resource_quotas: Optional[Dict[str, Any]] = None
    network_config: Optional[Dict[str, Any]] = None
    monitoring_config: Optional[Dict[str, Any]] = None
    backup_config: Optional[Dict[str, Any]] = None
    is_active: Optional[bool] = None


class Environment(EnvironmentBase):
    """环境响应模式"""
    id: int
    is_active: bool
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True
